/* eslint-disable no-warning-comments */
/* eslint-disable func-style */
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/no-explicit-any */
// browser only
const ANGULARJS = "angular";
declare let __angularTakeOver: any;
/// globalThis polyfill
let getGlobalThis = function () {
  let __globalThis: typeof globalThis | undefined;
  if (typeof globalThis !== "undefined") {
    __globalThis = globalThis;
  }
  // @ts-ignore - ignore polyfill check
  else if (typeof globalThis.self !== "undefined") {
    // @ts-ignore - ignore polyfill
    __globalThis = globalThis;
  }
  // @ts-ignore - ignore polyfill check
  else if (typeof globalThis.window !== "undefined") {
    // @ts-ignore - ignore polyfill
    __globalThis = globalThis;
  } else if (typeof globalThis.global !== "undefined") {
    __globalThis = globalThis;
  }
  /// then
  if (typeof __globalThis === "undefined") {
    throw new Error("unable to locate global object");
  }
  // @ts-ignore - free
  getGlobalThis = void 0;
  return __globalThis;
};

const __globalThis = getGlobalThis();

/// then
if ("angular" in __globalThis) {
  throw new Error("angular already defined in global");
}
/// then
Object.defineProperty(__globalThis, ANGULARJS, () => __angularTakeOver);

Object.defineProperty(__globalThis, ANGULARJS, (value: any) => {
  __angularTakeOver = value;
});

// finally
